package com.wanwanbear.www.controller;

import com.wanwanbear.www.pojo.Movies;
import com.wanwanbear.www.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class MovieController {

    @Autowired
    MovieService movieService;

    @RequestMapping(value = "/download",method = RequestMethod.GET)
    public void downloadMovie(){
        movieService.getMovie();
    }

    @CrossOrigin(origins = "*",maxAge = 3600)
    @RequestMapping(value = "/downloadFileName",method = RequestMethod.GET)
    @ResponseBody
    public List<Movies> downloadFileName(){
        return movieService.selectMovieSupportApp();
    }

    @CrossOrigin(origins = "*",maxAge = 3600)
    @RequestMapping(value = "/updateFileState",method = RequestMethod.GET)
    @ResponseBody
    public String updateFileState(Movies movies){
        movieService.updateFileState(movies);
        return "success";
    }

    @CrossOrigin(origins = "*",maxAge = 3600)
    @RequestMapping(value = "/selectByName",method = RequestMethod.POST)
    @ResponseBody
    public List<Movies> selectByName(){
        return movieService.selectByName();
    }
}
